# Contributor: Michael Pirogov <vbnet.ru@gmail.com>
# Maintainer: Michael Pirogov <vbnet.ru@gmail.com>
pkgname=isa-l
pkgver=2.30.0
pkgrel=1
pkgdesc="Intelligent Storage Acceleration Library"
url="https://github.com/intel/isa-l"
arch="all"
license="BSD-3-Clause"
source="$pkgname-$pkgver.tar.gz::https://github.com/intel/isa-l/archive/refs/tags/v$pkgver.tar.gz
	$pkgname-ec.patch
	$pkgname-sve-ec.patch
	$pkgname-s390x.patch
	$pkgname-i386.patch
	"
subpackages="$pkgname-static $pkgname-dev $pkgname-doc"
makedepends="autoconf automake help2man libtool linux-headers nasm"

case $CARCH in
	ppc64le|riscv64|s390x)
		;;
	*)
		makedepends="$makedepends texlive doxygen texmf-dist-latexextra"
		;;
esac

prepare() {
	default_prepare
	autoreconf -fi
}

build() {
	./configure --build=$CBUILD --host=$CHOST
	make
	if [ "$CARCH" != "ppc64le" ] && [ "$CARCH" != "riscv64" ] && [ "$CARCH" != "s390x" ]; then
		make doc
	fi
}

check() {
	make test
}

doc() {
	default_doc
	if [ "$CARCH" != "ppc64le" ] && [ "$CARCH" != "riscv64" ] && [ "$CARCH" != "s390x" ]; then
		mkdir -p "$subpkgdir"/usr/share/doc/$pkgname
		mv "$builddir"/${pkgname}_api_$pkgver.pdf "$subpkgdir"/usr/share/doc/$pkgname/
	fi
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="
d3ecfb7326097534b06a74b584100336509525ae7cadc6112d0c27e3d8704f3810e18f583d3cc33fa266bfec96db023607622b22ddbf17988ec4bf1bb3b3b9b2  isa-l-2.30.0.tar.gz
980ebc4280e83052862b36b8e1c2796c90249918f1889eb1acc51e95b8af27a185c3ab588038d7b6d7ea2ee9bc2af07e2a2772c0d5ded3314812019d18f613b2  isa-l-ec.patch
28cdb88e77f04ec9763c273007bb75f5d9e6f99bef5e83336bca2491ab9792db6bdaac092aa743783e9088e7c75475a8e97d1d26517d7f160953f3506a35bf6c  isa-l-sve-ec.patch
1d061b91ee62ac8f2dde3ea4f119b60341ecd3ffae156162969b5bc67fedef185f56a65e16153664ff380be2a3c39e7a4581e5d81dd5b3a4680a5ceb090a98ff  isa-l-s390x.patch
287177b0d9d88c824ffa2900d819cf1e3a9eff0d7c01c0f47671b7aee376777e45baf2cb18c6a46c20a399b789dd1230745c22e25850d1a03720395721d49da4  isa-l-i386.patch
"
